import axios from 'axios';

const API_URL = '/api/v1/receipts';

class ReceiptService {
  getAllReceipts(params = {}) {
    return axios.get(API_URL, { params });
  }

  createReceipt(receipt) {
    return axios.post(API_URL, receipt);
  }

  updateReceipt(id, receipt) {
    return axios.put(`${API_URL}/${id}`, receipt);
  }

  deleteReceipt(id) {
    return axios.delete(`${API_URL}/${id}`);
  }

  importReceipts(file) {
    const formData = new FormData();
    formData.append('file', file);
    return axios.post(`${API_URL}/import`, formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    });
  }

  exportReceipts(params) {
    return axios.get(`${API_URL}/export`, {
      params,
      responseType: 'blob'
    });
  }
}

export default new ReceiptService();